package com.example.a90610.face;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import java.io.File;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.get_token).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                final String filePath = getFilesDir().getAbsolutePath() +
                        File.separator+ "left.jpg";
                File file = new File(filePath);
                Log.e("MainActivity", String.valueOf(file.exists()));
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        FaceDetect.detect(filePath);
                    }
                }).start();
            }
        });
        findViewById(R.id.face_match).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                final String filePath1 = getFilesDir().getAbsolutePath() +
                        File.separator+ "left.jpg";
                final String filePath2 = getFilesDir().getAbsolutePath() +
                        File.separator+ "right.jpg";
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        FaceMatch.match(filePath1, filePath2);
                    }
                }).start();
            }
        });
    }
}
